<script setup>
import {onMounted, ref} from "vue";
import VerticalCard from '@/components/user_cover/VerticalPersonCard.vue';
import VideoPlayCard from '@/components/video_card/NormalPlay.vue';
import UserBox from "@/components/user_cover/UserBox.vue";
import CommentRow from "@/components/comment_row/NormalRow.vue";
import VideoCard from "@/components/video_card/NormalCard.vue";

onMounted(() => {
  if (flvjs.isSupported()) {
    var videoElement = document.getElementById('video');
    var flvPlayer = flvjs.createPlayer({
      type: 'flv',
      url: 'http://114.132.199.148/live/livestream.flv'
    });
    flvPlayer.attachMediaElement(videoElement);
    flvPlayer.load();
    flvPlayer.play();
  }
})

let ins = ref(0);
const active = (index) => {
  console.log(index);
  ins.value = index;
}

const tmpPartArr = ref([]);
for (let i = 0; i < 20; i++) {
  tmpPartArr.value.push(i);
}

let partHeight = ref('height: 75vh'), showChatBox = ref(false);
const swapChatBox = () => {
  if (showChatBox.value) {
    partHeight.value = 'height: 75vh';
    showChatBox.value = false;
  } else {
    partHeight.value = 'height: 35vh';
    showChatBox.value = true;
  }
}
const isOpenChatBoxMsg = (msg) => {
  showChatBox.value = msg;
  swapChatBox();
}

let partScrollbar = ref();
const onPartCardResize = () => {
  partScrollbar.value.update();
}
</script>

<template>
  <div class="container">
    <div class="l1">
      <VideoPlayCard @isOpenChatBoxMsg="isOpenChatBoxMsg"></VideoPlayCard>
      <div style="display: flex; height: 75vh; flex-direction: column; justify-content: space-between">
        <el-card class="part-card" :style="partHeight" :body-style="{ height: '100%', padding: '0px' }"
                 v-resize="onPartCardResize">
          <div class="card-header">
            <h3>课时</h3>
          </div>
          <div class="card-body">
            <el-scrollbar ref="partScrollbar">
              <ul class="part-items">
                <li v-for="(item, index) in tmpPartArr" @click="active(index)" class="part-item"
                    :class="{active:index === ins}">
                  <span class="block">&nbsp;</span>章节 {{ item + 1 }}
                </li>
              </ul>
            </el-scrollbar>
          </div>
        </el-card>
        <el-card class="chat-box" v-show="showChatBox" :body-style="{ padding: '0px' }">

        </el-card>
      </div>
    </div>

    <div class="l2" style="margin-top: 1rem">
      <div class="left-plane">
        <VerticalCard></VerticalCard>
      </div>
      <div class="right-plane">
        <div class="author-list">
          <div style="width: 8rem">
            <h3>致谢：</h3>
          </div>
          <el-scrollbar>
            <div style="display: flex">
              <div v-for="item in 20" class="author-item">
                <UserBox placement="bottom-end"></UserBox>
              </div>
            </div>
          </el-scrollbar>
        </div>
        <div class="bg-circle">
          <h2 style="font-weight: bold">课程简介</h2>
        </div>
        <div class="bg-rectangle">
          <el-scrollbar style="padding: 1rem">
            <p>sdfasdfasdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录手动阀的，发生的发，阿斯顿发生大是大非
              打发手动阀s 啊打发撒旦fasdf asdafsd asdfsd 阿迪斯fad 发生的
            </p>
            <p>sdfasdfasdfa sdfasd fasd fasd fasd fsddfa零三分德拉夫斯基的sfasd
              f立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录</p>
            <p>sdfasdfaadfaa sdfads sdasd asd fsdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录手动阀的，发生的发，阿斯顿发生大是大非
              打发手动阀s 啊dafasd fdasd fads打发撒旦fasd 阿迪斯fad 发生的
            </p>
            <p>sdfasdfasd fasdfasd asdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录</p>
            <p>sdfasdfasd fasdfasd asdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录</p>
            <p>sdfasdfaadfaa sdfads sdasd asd fsdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录手动阀的，发生的发，阿斯顿发生大是大非
              打发手动阀s 啊dafasd fdasd fads打发撒旦fasd 阿迪斯fad 发生的
            </p>
            <p>sdfasdfaadfaa sdfads sdasd asd fsdfa零三分德拉夫斯基的立刻发酵饲料的爱发牢骚拉萨扩大飞机拉客的记录手动阀的，发生的发，阿斯顿发生大是大非
              打发手动阀s 啊dafasd fdasd fads打发撒旦fasd 阿迪斯fad 发生的
            </p>
          </el-scrollbar>
          <div class="image-box">
            <el-image src="https://i.postimg.cc/RVQyz4F5/luyeplus-Flat-illustration-of-online-course-Minialistic2-D-Low-s-d8cbf53a-37e0-4fa6-b84a-ad37706c1416.png"></el-image>
          </div>
        </div>
      </div>
    </div>

    <el-divider/>

    <div class="l3" style="margin-top: 1rem">
      <div class="left-plane">
        <div class="title">
          <h2>评论</h2>
          <span style="margin-left: 0.5rem; margin-right: 1.5rem; font-size: 14px; color: #909399">2313</span>
          <el-link>热度</el-link>
          <el-divider direction="vertical"/>
          <el-link>最新</el-link>
        </div>
        <div class="comment-li">
          <CommentRow></CommentRow>

          <div style="text-align: center; font-size: 14px; color: #909399">没有更多了</div>
        </div>

        <div style="height: 20vh">

        </div>
      </div>
      <div class="right-plane">
        <div v-for="item in 2" class="video-item">
          <VideoCard></VideoCard>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.container .l3 {
  display: flex;
  justify-content: space-between;
}

.container .l3 .left-plane {
  height: 20rem;
  width: 70%;
}

.container .l3 .left-plane .title {
  display: flex;
  align-items: end;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--el-border-color);
}

.container .l3 .left-plane .comment-li {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

.container .l3 .right-plane {
  width: 28%;
}
.container .l3 .right-plane .video-item {
  margin-bottom: 1rem;
}


.part-card {
  width: 17vw;
  display: flex;
  flex-direction: column;
}

.part-card .card-header {
  height: 3rem;
  padding: 0.5rem 1rem 0.5rem 1rem;
  border-bottom: #DCDFE6 solid 1px;
}

.part-card .card-body {
  height: calc(100% - 3rem);
  padding: 0 0 1rem 0;
}

.chat-box {
  width: 17vw;
  height: 38vh;
}

.part-items {
  list-style: none;
  padding: 0 1rem 0 1rem;
  line-height: 1.5;
}

.part-item {
  margin-top: 10px;
  font-size: 13px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  padding: 0.3rem 1rem 0.3rem 0.5rem;
  cursor: pointer;
  border-radius: 0.5rem;
}

.part-item .block {
  margin-right: 0.5rem;
  border-radius: 1rem;
}

.part-item.active .block {
  background-color: var(--el-color-primary);
}

.part-item.active {
  background-color: #ecf5ff;
}

.part-item:hover {
  background-color: #ecf5ff;
  color: var(--el-color-primary);
}

.container {
  display: flex;
  flex-direction: column;
}

.container .l1 {
  display: flex;
  place-content: space-between;
  width: 100%;
}

.container .l2 {
  display: flex;
}

.container .l2 .left-plane {
  width: 20%;
}

.container .l2 .right-plane {
  width: 80%;
  margin-left: 1rem;
}

.container .l2 .right-plane .author-list {
  background-color: #d9ecff;
  width: 73%;
  height: 4rem;
  margin-bottom: -3rem;
  float: right;
  border-bottom-left-radius: 1.5rem;
  padding: 0 1rem 0 1rem;
  display: flex;
}

.container .l2 .right-plane .author-list:before {
  content: '';
  position: absolute;
  bottom: -7rem;
  right: 0;
  height: 10rem;
  width: 7rem;
  background: radial-gradient(circle at 0% 100%, transparent 7rem, #d9ecff 0)
}

.container .l2 .right-plane .author-list:after {
  content: '';
  position: absolute;
  top: 0;
  left: -3.5rem;
  height: 3rem;
  width: 3.5rem;
  background: radial-gradient(circle at 0% 100%, transparent 3.5rem, #d9ecff 0);
}

.container .l2 .right-plane .author-list .author-item {
  height: 3.5rem;
  width: 3.5rem;
  margin: 0 0.5rem 0 0.5rem;
}

.container .l2 .right-plane .bg-circle {
  width: 15rem;
  height: 5rem;
  background-color: #ecf5ff;
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  text-align: center;
  padding: 1.5rem;
}

.container .l2 .right-plane .bg-circle:after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -3rem;
  height: 3rem;
  width: 3rem;
  background: radial-gradient(circle at 100% 0%, transparent 3rem, #ecf5ff 0)
}

.container .l2 .right-plane .bg-rectangle {
  background-color: #ecf5ff;
  width: 100%;
  height: 15rem;
  border-top-right-radius: 10rem;
  display: flex;
  padding: 0.5rem;
}

.container .l2 .right-plane .bg-rectangle .el-scrollbar {
  z-index: 2;
  width: 50rem;
}

.container .l2 .right-plane .bg-rectangle .image-box {
  position: absolute;
  width: 15rem;
  height: 15rem;
  z-index: 1;
  right: 0;
  bottom: 0;
}
</style>